package com.health.view.spinner;

import java.util.List;

import android.content.Context;

/**
 * @author angelo.marchesin
 */

public class NiceSpinnerAdapter<T> extends NiceSpinnerBaseAdapter {

	private final List<T> mItems;

	public NiceSpinnerAdapter(Context context, List<T> items) {
		super(context);
		mItems = items;
	}

	@Override
	public int getCount() {
		return mItems.size() - 1;
	}

	@Override
	public T getItem(int position) {
		if (!mItems.isEmpty()) {
			if (position >= mSelectedIndex) {
				return mItems.get(position + 1);
			} else {
				return mItems.get(position);
			}
		}
		return null;
	}

	@Override
	public T getItemInDataset(int position) {
		if (!mItems.isEmpty() && position <= mItems.size()) {
			return mItems.get(position);
		}
		return null;
	}
}